#include "unlinkgitsolution.h"

UnlinkGitSolution::UnlinkGitSolution() {}

QString UnlinkGitSolution::name()
{
    return "移除 git 软链接";
}

QString UnlinkGitSolution::state()
{
    return "可移除";
}

bool UnlinkGitSolution::solution(const QString &workdir, const QString &name, const QString &path)
{
    auto realpath = path_in_work(workdir, path, ".git");
    return QFileInfo(realpath).exists();
}

bool UnlinkGitSolution::solution_apply(const QString &workdir, const QString &name, const QString &path)
{
    auto realpath = path_in_work(workdir, path, ".git");
    QFileInfo info(realpath);
    if (info.isSymLink()) {
        return QFile(info.filePath()).remove();
    }
    return false;
}

bool UnlinkGitSolution::solution_undo(const QString &workdir, const QString &name, const QString &path)
{
    auto realpath = path_in_work(workdir, path, ".git");
    QFileInfo info(realpath);
    if (info.isSymLink()) {
        return QFile(info.filePath()).remove();
    }
    return false;
}
